package proxy.pattern;

/**
 * @description: ToDo
 * @author: marin
 * @time: 2020/7/6 18:50
 */
public class Proxy {

    private RealSubject realSubject;
    public void request(){
        if (realSubject == null) {
            realSubject = new RealSubject();
        }
        preRequest();
        realSubject.request();
        postRequest();
    }
    public void preRequest(){
        System.out.println("代理方法执行前先执行");
    }
    public void postRequest(){
        System.out.println("代理方法执行后执行");
    }
    public static void main(String[] args) {
        Proxy proxy = new Proxy();
        proxy.request();
    }
}
